<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt" %>

<fmt:setBundle basename="ApplicationResources" />

<c:if test="${not empty requestScope.course}">

  <table cellspacing="5">
    <tr>
      <th align="right"><fmt:message key="fieldLabel.courseId"/></th>
      <td colspan="3">
        <c:out value="${course.courseId}"/>
      </td>
    </tr>
    <tr>
      <th align="right"><fmt:message key="fieldLabel.courseName"/></th>
      <td colspan="3">
        <c:out value="${course.courseName}"/>
      </td> 
    </tr>
    <tr>
      <th align="right"><fmt:message key="fieldLabel.organiser"/></th>
      <td colspan="3">
        <c:out value="${course.organiser}"/>
      </td>
    </tr>
    <tr>
      <th align="right"><fmt:message key="fieldLabel.startDate"/></th>
      <td>
        <fmt:formatDate value="${course.fromDate}"
                      pattern="${APPL_DATE_FORMAT}"/>
      </td>
      <th align="right"><fmt:message key="fieldLabel.endDate"/></th>
      <td>
        <fmt:formatDate value="${course.toDate}"
                      pattern="${APPL_DATE_FORMAT}"/>
      </td>
    </tr>
    <tr>
      <th align="right"><fmt:message key="fieldLabel.fees"/></th>
      <td>
        <c:out value="${course.fees}"/>
      </td>
      <th align="right"><fmt:message key="fieldLabel.gstIncluded"/></th>
      <td>
        <c:choose>
          <c:when test="${course.gstIncluded}"><fmt:message key="caption.yes"/></c:when>
          <c:otherwise><fmt:message key="caption.no"/></c:otherwise>
        </c:choose>
      </td>
    </tr>
    <tr>
      <th align="right"><fmt:message key="fieldLabel.justification"/></th>
      <td colspan="3">
        <c:out value="${course.justification}"/>
      </td>   
    </tr>
    <tr>
      <th align="right"><fmt:message key="fieldLabel.status"/></th>
      <td colspan="3">
        <c:out value="${course.status}"/>
      </td>   
    </tr>
  </table>

  <c:if test="${updateCourse}">
    <table>
      <tr>
        <td width="75">&nbsp;</td>
        <td>
          <c:url var="url" value="/protected/courseManage.do?method=view">
            <c:param name="course_id" value="${course.courseId}" />
          </c:url>
          <a href="<c:out value="${url}"/>">
            <img src="img/button_update.gif" width="59" height="22" alt="" border="0">
          </a>
          &nbsp; &nbsp; &nbsp; &nbsp;
          <c:url var="url" value="/protected/courseManage.do?method=withdraw">
            <c:param name="course_id" value="${course.courseId}" />
          </c:url>
          <a href="<c:out value="${url}"/>">
            <img src="img/button_withdraw.gif" width="59" height="22" alt="" border="0">
          </a>
        </td>
      </tr>
    </table>
  </c:if>

  <c:if test="${approveCourse}">
    <h3><fmt:message key="title.courseDetailsApproval"/></h3>
    
    <c:url var="url" value="/manager/courseApprove.do">
      <c:param name="course_id" value="${course.courseId}" />
    </c:url>
    <form action="<c:out value="${url}"/>" method="POST">
      <table>
        <tr>
          <td>
           <input type="radio" name="decision" value="approve"><fmt:message key="caption.approve"/>
           &nbsp;&nbsp;
           <input type="radio" name="decision" value="reject"><fmt:message key="caption.reject"/>
          </td>
        </tr>
        <tr>
          <td>
            <fmt:message key="fieldLabel.managerComment"/><br>
            <textarea name="comment" cols="60" rows="4"></textarea>
          </td>
        </tr>
      </table>
      <button type="submit">
        <img src="img/button_submit.gif" width="59" height="22" alt="" border="0">
      </button>
    </form>

  </c:if>

  <h3><fmt:message key="title.courseDetailsHistory"/></h3>
  <table width="100%" cellspacing="2" cellpadding="2" border="1">
    <tr>
      <th><fmt:message key="fieldLabel.actionDate"/></th>
      <th><fmt:message key="fieldLabel.actionTaken"/></th>
      <th><fmt:message key="fieldLabel.actionBy"/></th>
      <th><fmt:message key="fieldLabel.actionComment"/></th>
    </tr>

    <c:forEach var="event" items="${course.courseEvents}">

      <tr>
        <td>
          <fmt:formatDate value="${event.timeStamp}"
                          pattern="${APPL_DATE_FORMAT}"/>
        </td>
        <td>
          <c:out value="${event.eventType}"/>
        </td>
        <td>
                  <c:out value="${event.eventBy}"/>
        </td>
        <td>
          <c:out value="${event.comment}"/>
        </td>
      </tr>
    </c:forEach>

  </table>
</c:if>

